//
//  TTProgressHUD.h
//  Tint
//
//  Created by Kevin Wu on 2/28/12.
//  Copyright (c) 2012 Telligenty. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>


typedef enum {
    TTProgressHUDModeIndeterminate = 0, 
	TTProgressHUDModeDeterminate, 
    TTProgressHUDModeSuccess, 
    TTProgressHUDModeFailure, 
    TTProgressHUDModeCustomView
} TTProgressHUDMode;


@protocol TTProgressHUDDelegate;

@interface TTProgressHUD : UIView {
    
    id<TTProgressHUDDelegate> _delegate;
    
    // Appearance
    TTProgressHUDMode _modeType;
    CGFloat _opacity;
    BOOL _dimBackground;
    UIView *_customIndicator;
    NSString *_info;
    UIView *_indicator;
    UILabel *_label;
    
    // Metrics
    BOOL _square;
    CGSize _minSize;
    CGFloat _margin;
    CGFloat _spacing;
    CGPoint _offset;
    CGFloat _hudWidth;
    CGFloat _hudHeight;
    
    // Progress
    CGFloat _progress;
    
    // Time
    CGFloat _graceTime;
    CGFloat _minShowTime;
    NSDate *_startDate;
}

@property(nonatomic, assign) id<TTProgressHUDDelegate> delegate;

@property(nonatomic, assign) TTProgressHUDMode modeType;
@property(nonatomic, assign) CGFloat opacity; // Defaults to 0.8 (80% opacity)
@property(nonatomic, assign) BOOL dimBackground;
@property(nonatomic, retain) UIView *customIndicator; // Used only when the mode is MBProgressHUDModeCustomView, and for best results use a 37 by 37 pixel view.
@property(nonatomic, copy) NSString *info;
@property(nonatomic, readonly) UIView *indicator;
@property(nonatomic, readonly) UILabel *label;

@property(nonatomic, assign) BOOL square;
@property(nonatomic, assign) CGSize minSize;
@property(nonatomic, assign) CGFloat margin;
@property(nonatomic, assign) CGFloat spacing;
@property(nonatomic, assign) CGPoint offset; // The offset of the HUD relative to the centre of the superview.
@property(nonatomic, readonly) CGFloat hudWidth;
@property(nonatomic, readonly) CGFloat hudHeight;

@property(nonatomic, assign) CGFloat progress;

@property(nonatomic, assign) CGFloat graceTime;
@property(nonatomic, assign) CGFloat minShowTime;
@property(nonatomic, readonly) NSDate *startDate;


- (void)presentAnimated:(BOOL)animated;
- (void)dismissAnimated:(BOOL)animated;
- (void)showAnimated:(NSNumber *)animated;
- (void)hideAnimated:(NSNumber *)animated;
- (void)dismissAnimated:(BOOL)animated afterDelay:(NSTimeInterval)delay;

+ (TTProgressHUD *)makeHUDForView:(UIView *)view;
+ (TTProgressHUD *)presentHUDInView:(UIView *)view info:(NSString *)info animated:(BOOL)animated;
+ (void)dismissHUDFromView:(UIView *)view animated:(BOOL)animated;
+ (void)dismissHUDFromView:(UIView *)view state:(BOOL)state info:(NSString *)info animated:(BOOL)animated;

+ (TTProgressHUD *)findHUDInView:(UIView *)view;
+ (BOOL)containsHUDInView:(UIView *)view;

@end


@protocol TTProgressHUDDelegate <NSObject>
@optional
- (void)hudWillPresent:(TTProgressHUD *)hud;
- (void)hudDidDismiss:(TTProgressHUD *)hud;
@end
